package user_db

import (
	database "hft/Database"
	"time"
)

// 客户系统
type User struct {
	database.Base
	UUID              string      `json:"uuid"`                                             //uuid
	Phone             string      `json:"phone" gorm:"uniqueIndex:phone_city;comment:客户手机"` //手机
	City              int         `json:"city" gorm:"uniqueIndex:phone_city;comment:城市ID"`  //城市
	CityLink          string      `json:"city_link"`
	CityName          string      `json:"city_name"`
	Username          string      `json:"username" gorm:"comment:客户名称;not null"`               //客户姓名
	WeChat            string      `json:"we_chat" gorm:"comment:微信号"`                          //微信号
	Alternative       string      `json:"alternative" gorm:"comment:备用手机号"`                    //备用手机号
	IntendLou         string      `json:"intend_lou" gorm:"comment:意向楼盘"`                      //意向楼盘
	IntendPrice       string      `json:"intend_price" gorm:"comment:意向价格"`                    //意向价格
	IntendLouID       uint        `json:"intend_lou_id"`                                       //意向楼盘ID
	Level             string      `json:"level" gorm:"comment:评级;default:D"`                   //评级
	RemarkInfo        string      `json:"remark_info" gorm:"comment:备注"`                       //备注
	ManagerID         int         `json:"manager_id" gorm:"comment:经纪人ID"`                     //当前管理的经纪人
	ManagerName       string      `json:"manager_name" gorm:"comment:经纪人名称"`                   //经纪人名称
	UseProtectTimes   int         `json:"use_protect_times" gorm:"comment:使用产品次数;default:1"`   //使用产品次数
	HistoryManagerNum int         `json:"history_manager_num" gorm:"comment:跟进次数;default:0"`   //历史跟进管家人次
	IsValid           bool        `json:"is_valid" gorm:"comment:是否验证;default:0"`              //是否验证
	IsShield          bool        `json:"is_shield" gorm:"comment:是否屏蔽;default:0"`             //是否屏蔽
	NewestClueTime    time.Time   `json:"newest_clue_time" gorm:"comment:最新跟进时间;default:null"` //最新跟进时间
	ReleaseTime       time.Time   `json:"release_time" gorm:"comment:释放时间;default:null"`       //释放时间
	Sex               int         `json:"sex" gorm:"column:sex;type:tinyint(1);default:0"`
	Delivery          string      `json:"delivery" gorm:"default:''"`
	LouCategory       string      `json:"lou_category" gorm:"default:''"`
	Fitment           string      `json:"fitment" gorm:"default:''"`
	Floor             string      `json:"floor" gorm:"default:''"`
	Aim               string      `json:"aim" gorm:"default:''"`
	ReceiceTime       time.Time   `json:"receice_time" gorm:"default:null"`
	FirstClueTime     time.Time   `json:"first_clue_time" gorm:"default:null"` //首次录入时间
	ProtectStartTime  time.Time   `json:"protect_start_time" gorm:"default:null"`
	ExtendInfo        ExtendInfo  `json:"extend_info" gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE"` //扩展内容
	Clues             []*Clue     `json:"clues" gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE"`       //线索
	FollowUps         []*FollowUp `json:"follow_ups" gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE"`  //跟进记录
	File              int         `json:"file" gorm:"default:0"`
	Show              int         `json:"show" gorm:"default:0"`
	Tag               int         `json:"tag" gorm:"default:0"`
}

func (User) TableName() string {
	return database.TableNameFormat("front_user")
}
